﻿using System;
using System.Text;
using System.Data;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTcms.Common;

namespace DTcms.Web.admin.company
{
    public partial class company_albumns_list : Web.UI.ManagePage
    {
        protected int albums_id = 0;
        protected int company_id = 0;
        private string action = DTEnums.ActionEnum.Add.ToString(); //操作类型
        BLL.company_albums bllcomalbums = new BLL.company_albums();
        protected void Page_Load(object sender, EventArgs e)
        {
            string _action = DTRequest.GetQueryString("action");
            this.company_id = DTRequest.GetQueryInt("company_id");
            this.albums_id = DTRequest.GetQueryInt("albums_id");
            if (!string.IsNullOrEmpty(_action) && _action == DTEnums.ActionEnum.Edit.ToString())
            {
                this.action = DTEnums.ActionEnum.Edit.ToString();//修改类型
                if (this.albums_id == 0)
                {
                    JscriptMsg("传输参数不正确！", "back");
                    return;
                }

            }
            if (!Page.IsPostBack)
            {
                this.rptList.DataSource = bllcomalbums.GetList(" company_id=" + company_id);
                this.rptList.DataBind();
            }
        }









        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            //ChkAdminLevel("sys_channel_manage", DTEnums.ActionEnum.Delete.ToString());//检查权限
            int sucCount = 0;
            int errorCount = 0;
            BLL.company bll = new BLL.company();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    if (bll.Delete(id))
                    {
                        sucCount += 1;
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            JscriptMsg("删除成功" + sucCount + "条，失败" + errorCount + "条！",
                Utils.CombUrlTxt("company_list.aspx", "company_id={0}&company_id={1}", this.company_id.ToString(), this.albums_id.ToString()), "parent.loadMenuTree");
        }



        protected void btnSubmit_Click1(object sender, EventArgs e)
        {
            this.company_id = DTRequest.GetQueryInt("company_id");
            this.albums_id = DTRequest.GetQueryInt("albums_id");
            BLL.common_albums bllcomalbums = new BLL.common_albums();
            
        }
    }
}